<template>
  <el-menu
    :default-active="$route.path"
    class="el-menu-vertical-demo"
    @open="handleOpen"
    @close="handleClose"
    :router="true"
    :unique-opened="true"
  >
    <el-submenu :index="item.index" v-for="item in subData" :key="item.index">
      <template slot="title">
        <i :class="item.icon"></i>
        <span>{{ item.title }}</span>
      </template>
      <el-menu-item
        v-for="it in item.subMenu"
        :key="it.index"
        :index="it.index"
        >{{ it.title }}</el-menu-item
      >
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  data() {
    return {
      subData: [
        {
          index: "1",
          title: "管理员管理",
          icon: "el-icon-s-custom",
          subMenu: [
            {
              index: "/home/usersAdd",
              title: "新增管理员",
            },
            {
              index: "/home/usersList",
              title: "管理员列表",
            },
          ],
        },
        {
          index: "2",
          title: "轮播图管理",
          icon: "el-icon-s-custom",
          subMenu: [
            {
              index: "/home/CarouselAdd",
              title: "新增轮播图",
            },
            {
              index: "/home/CarouselList",
              title: "轮播图列表",
            },
          ],
        },
        {
          index: "3",
          title: "菜谱管理",
          icon: "el-icon-coordinate",
          subMenu: [
            {
              index: "/home/DishesList",
              title: "菜品展示",
            },
          ],
        },
        {
          index: "4",
          title: "会员管理",
          icon: "el-icon-s-platform",
          subMenu: [
            {
              index: "/home/vip",
              title: "后端充值会员",
            },
            {
              index: "/home/VipList",
              title: "会员列表",
            },
          ],
        },
        {
          index: "5",
          title: "套餐管理",
          icon: "el-icon-reading",
          subMenu: [
            {
              index: "/home/mealList",
              title: "套餐列表",
            },
            {
              index: "/home/mealAdd",
              title: "新增套餐",
            },
          ],
        },
      ],
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style></style>
